home *** CD-ROM | disk | FTP | other *** search
- rem $linesize:132
- rem $title:'Application Engineer Standard Routines'
- rem $subtitle:'Find a key in the index'
- '
- ' find a key in the index. if the find was a success, then two values
- ' are actually returned. success% holds the pointer to the physical
- ' position on the index, while mrec% returns the master record number.
- ' the find actually returns a match directly on the key being looked for.
- ' if there was no direct match, then ky$ will return the match before
- ' the return, mrec% will have a minus record number value, and success%
- ' will return the pointer into the index - for the bit.next and bit.prev
- ' routines to use.
- '
- ' Include the COMMON values
- rem $include:'AESHARED.BAS'
-
-
- sub bit.find(fl%,ky$,mrec%,success%) static
-
- mrec%=0
- success%=0
- if len(ky$)<xh%(fl%,1) then
- ky$=ky$+string$(xh%(fl%,1)-len(ky$),32)
- end if
- rrec%=1
- loop%=0%
-
- while loop%=0%
- prrec%=rrec% ' hold the recnum for eval
- get #fl%,rrec%
- if cvi(xk$(fl%,5))=0 then
- goto fplace ' this is end of chain
- elseif ky$<xk$(fl%,1) then
- side%=2%
- elseif ky$>xk$(fl%,1) then
- side%=3%
- else
- success%=rrec%
- mrec%=cvi(xk$(fl%,5%))
- goto ffound
- end if
- rrec%=cvi(xk$(fl%,side%))
- if rrec%=0% then
- goto fplace
- end if
- wend
-
- fplace:
- mrec%=-cvi(xk$(fl%,5))
- success%=prrec%
- ky$=xk$(fl%,1)
-
- ffound:
-
- end sub